local S = minetest.get_translator("default")

local treasure1={
	description = "".. core.colorize("#BFFFFF", S("Wooden loot crate").."\n")..core.colorize("#A0A0A0", "tier: 2 ("..S("uncommon")..")"),
tiles = {"treasures_treasure1.png"},
groups = {cracky = 3, choppy = 3},
drop = {
	max_items = 5,
	items = {}
},
}

local treasure2 = {
	description = "".. core.colorize("#00FFFF", S("Sturdy wooden loot crate").."\n")..core.colorize("#A0A0A0", "tier: 3 ("..S("almost rare")..")"),
tiles = {"treasures_treasure2.png"},
groups = {cracky = 2, choppy = 2},
drop = {
	max_items = 5,
	items = {}
},
}

local treasure3 = {
	description = "".. core.colorize("#40FF80", S("Reinforced wooden loot crate").."\n")..core.colorize("#A0A0A0", "tier: 4 ("..S("rare")..")"),
tiles = {"treasures_treasure3.png"},
groups = {cracky = 3, choppy = 3},
drop = {
	max_items = 5,
	items = {}
},
}

local treasure4 = {
	description = "".. core.colorize("#0040FF", S("Well-reinforced wooden loot crate").."\n")..core.colorize("#A0A0A0", "tier: 5 ("..S("extra rare")..")"),
tiles = {"treasures_treasure4.png"},
groups = {cracky = 3, choppy = 1},
drop = {
	max_items = 5,
	items = {}
},
}

local treasure5 = {
	description = "".. core.colorize("#00FF00", S("Steel loot crate").."\n")..core.colorize("#A0A0A0", "tier: 6 ("..S("epic")..")"),
tiles = {"treasures_treasure5.png"},
groups = {cracky = 3},
drop = {
	max_items = 5,
	items = {}
},
}

local treasure1_items={
	{items = {'default:sword_steel 1'},rarity = 25,},
	{items = {'default:wood 5'},rarity = 5,},
	{items = {'default:stick 5'},rarity = 5,},
	{items = {'default:torch 10'},rarity = 5,},
	{items = {'default:apple 3'},rarity = 5,},
	{items = {'default:coal_lump 3'},rarity = 10,},
	{items = {'default:flint 2'},rarity = 10,},
	{items = {'default:iron_lump 3'},rarity = 15,},
	{items = {'default:copper_lump 3'},rarity = 15,},
	{items = {'default:tin_lump 3'},rarity = 15,},
	{items = {'farming:bread 2'},rarity = 5,},
	{items = {'farming:string 4'},rarity = 5,},
	{items = {'basic_materials:plastic_sheet 5'},rarity = 10,},
	{items = {'basic_materials:oil_extract 5'},rarity = 10,},
	{items = {'basic_materials:wet_cement 5'},rarity = 10,},
	}

local treasure2_items = {
	{items = {'default:tree 5'},rarity = 5,},
	{items = {'default:wood 5'},rarity = 5,},
	{items = {'default:torch 15'},rarity = 5,},
	{items = {'default:blueberries 3'},rarity = 5,},
	{items = {'default:coal_lump 5'},rarity = 10,},
	{items = {'default:steel_ingot 3'},rarity = 10,},
	{items = {'default:ladder_wood 15'},rarity = 5,},
	{items = {'default:paper 10'},rarity = 5,},
	{items = {'default:gold_lump 3'},rarity = 15,},
	{items = {'default:mese_crystal 3'},rarity = 15,},
	{items = {'default:diamond 2'},rarity = 20,},
	{items = {'default:desert_stone 5'},rarity = 10,},
	{items = {'farming:bread 5'},rarity = 5,},
	{items = {'farming:string 8'},rarity = 5,},
	{items = {'basic_materials:plastic_sheet 10'},rarity = 10,},
	{items = {'basic_materials:oil_extract 10'},rarity = 15,},
	{items = {'basic_materials:wet_cement 10'},rarity = 10,},
}

local treasure3_items = {
	{items = {'default:tree 5'},rarity = 5,},
	{items = {'default:obsidian_shard 5'},rarity = 10,},
	{items = {'default:paper 15'},rarity = 5,},
	{items = {'default:torch 25'},rarity = 5,},
	{items = {'default:coal_lump 8'},rarity = 10,},
	{items = {'default:steel_ingot 5'},rarity = 10,},
	{items = {'default:ladder_wood 20'},rarity = 5,},
	{items = {'default:diamond 5'},rarity = 15,},
	{items = {'default:desert_stone 5'},rarity = 5,},
	{items = {'farming:coffee_cup 2'},rarity = 5,},
	{items = {'basic_materials:brass_ingot 4'},rarity = 10,},
	{items = {'basic_materials:empty_spool 6'},rarity = 15,},
	{items = {'basic_materials:silicon 10'},rarity = 10,},
}

local treasure4_items = {
	{items = {'default:diamond 5'},rarity = 5,},
	{items = {'default:torch 35'},rarity = 5,},
	{items = {'default:obsidian 5'},rarity = 10,},
	{items = {'default:coal_lump 10'},rarity = 10,},
	{items = {'default:steel_ingot 8'},rarity = 10,},
	{items = {'default:ladder_wood 25'},rarity = 5,},
	{items = {'default:desert_stone 10'},rarity = 5,},
	{items = {'default:obsidian 5'},rarity = 10,},
	{items = {'farming:coffee_cup 4'},rarity = 5,},
	{items = {'basic_materials:brass_ingot 8'},rarity = 10,},
	{items = {'basic_materials:copper_wire 4'},rarity = 15,},
	{items = {'basic_materials:gold_wire 2'},rarity = 20,},
	}

local treasure5_items = {
	{items = {'default:torch 50'},rarity = 5,},
	{items = {'default:steel_ingot 10'},rarity = 10,},
	{items = {'default:ladder_steel 30'},rarity = 5,},
	{items = {'default:obsidian 10'},rarity = 10,},
	{items = {'default:desert_stone 10'},rarity = 5,},
	{items = {'default:diamond 5'},rarity = 15,},
	{items = {'basic_materials:brass_ingot 8'},rarity = 5,},
	{items = {'basic_materials:copper_wire 6'},rarity = 20,},
	{items = {'basic_materials:gold_wire 4'},rarity = 25,},
	}


for _,v in pairs(treasure1_items) do
	local add_item = v.items[1]
	if minetest.registered_items[add_item:split(" ")[1]] ~= nil then
		table.insert(treasure1.drop.items,math.random(1,#treasure1.drop.items),v)
	end
end
treasures.add_treasure("treasures:treasure1", treasure1)

for _,v in pairs(treasure2_items) do
	local add_item = v.items[1]
	if minetest.registered_items[add_item:split(" ")[1]] ~= nil then
		table.insert(treasure2.drop.items,math.random(1,#treasure2.drop.items),v)
	end
end

treasures.add_treasure("treasures:treasure2", treasure2)

for _,v in pairs(treasure3_items) do
	local add_item = v.items[1]
	if minetest.registered_items[add_item:split(" ")[1]] ~= nil then
		table.insert(treasure3.drop.items,math.random(1,#treasure3.drop.items),v)
	end
end

treasures.add_treasure("treasures:treasure3", treasure3)

for _,v in pairs(treasure4_items) do
	local add_item = v.items[1]
	if minetest.registered_items[add_item:split(" ")[1]] ~= nil then
		table.insert(treasure4.drop.items,math.random(1,#treasure4.drop.items),v)
	end
end

treasures.add_treasure("treasures:treasure4", treasure4)

for _,v in pairs(treasure5_items) do
	local add_item = v.items[1]
	if minetest.registered_items[add_item:split(" ")[1]] ~= nil then
		table.insert(treasure5.drop.items,math.random(1,#treasure5.drop.items),v)
	end
end

treasures.add_treasure("treasures:treasure5", treasure5)
